package DP;

/**
 * @author 曹见朋
 * @create 2024-06-11-22:22
 */
public class Main70 {
    // TODO 70. 爬楼梯
    public static int climbStairs(int n) {
        // 1. 确定dp数组及下标的含义
        int[] dp = new int[n];

        // 2. 递推公式 dp[i] = dp[i - 1] + dp[i - 2]

        // 3. dp数组初始化
        dp[0] = 1;
        dp[1] = 2;

        // 4. 遍历dp数组
        for(int i = 2; i < n; i++){
            dp[i] = dp[i - 1] + dp[i - 2];
        }

        // 5. 打印dp数组
        for(int i = 0; i < n; i++){
            System.out.print(dp[i] + " ");
        }
        return dp[n - 1];
    }

    public static void main(String[] args) {
        int n = 6;
        int result = climbStairs(n);
        System.out.println();
        System.out.println(n);
    }
}
